using System;
using System.Collections.Generic;
using System.Text;
using AF_ORM.CORE;
using System.Data;
using System.Globalization;
namespace Bussiness.Manager
{
                

    public class PT_PTMV_HistoryManager:Bussiness.ManagerBase.PT_PTMV_HistoryManagerBase
    {
        public static PT_PTMV_HistoryManager CreateInstant()
        {
            return new PT_PTMV_HistoryManager();
        }
        public DateTime getLastDate()
        {
            string sql = "SELECT TOP(1) * FROM PT_PTMV_History ORDER BY CreatedDate DESC";
            DataTable dt = SqlHelper.ExecuteDataTable(Config.ConnectionConfig.ConnectionString, CommandType.Text, sql);
            if (dt.Rows.Count > 0)
            {
                string date = dt.Rows[0]["STOCK_OUT_DAT"].ToString();
                try
                {
                    DateTime theTime = DateTime.ParseExact(date, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None);
                    return theTime;
                }
                catch (Exception ex)
                {
                    return DateTime.Now;
                }
            }
            else
                return DateTime.Now;
        }
    }
}
                    
